package w3

class Person {
  val page = 18
  private val pname: String = "Jack"

  def getName = pname

  def sayHello() = println(s"my name is ${pname},and is ${page} years old")
}

class Children extends Person {
  override val page = 21

  override def sayHello() = {
    println(s"我的名字是${getName},今年${page}")
    super.sayHello()
  }
}

object JichengExample {
  def main(args: Array[String]): Unit = {
    var p1 = new Children()
    p1.sayHello()
    var p2: Person = new Children
    p2.sayHello() //21 or 18?
  }
}
